package com.repair.order.validator;

import com.repair.order.exception.OrderException;
import com.repair.order.pojo.dto.OrderCreateParam;

/**
 * @author chunyu
 * @since 2024/10/2,15:41
 */
public abstract class BaseOrderCreateValidate implements OrderCreateValidator{

    protected OrderCreateValidator nextValidate;

    @Override
    public void setNext(OrderCreateValidator nextValidate) {
        this.nextValidate = nextValidate;
    }

    @Override
    public OrderCreateValidator getNext() {
        return nextValidate;
    }

    @Override
    public void validate(OrderCreateParam orderCreateParam) {
        doValidate(orderCreateParam);

        if (nextValidate != null) {
            nextValidate.validate(orderCreateParam);
        }
    }

    /**
     * 具体校验的方法
     * @param orderCreateParam
     * @throws OrderException
     */
    protected abstract void doValidate(OrderCreateParam orderCreateParam) throws OrderException;


}
